package priv.bestbeat.cloud.api.gateway.configurations.security;

import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.server.authorization.ServerAccessDeniedHandler;
import org.springframework.web.server.ServerWebExchange;
import priv.bestbeat.cloud.api.gateway.utils.ReactiveServerHttpUtil;
import reactor.core.publisher.Mono;

/**
 * 用户访问拒绝处理器
 * @author 张渠钦
 * @date 2022/1/5 17:41
 */
public class UserAccessDeniedHandler implements ServerAccessDeniedHandler {
    @Override
    public Mono<Void> handle(ServerWebExchange exchange, AccessDeniedException denied) {
        ServerHttpResponse serverHttpResponse = exchange.getResponse();
        return ReactiveServerHttpUtil.sendMono(serverHttpResponse,"1");
    }
}
